.. _`Jinja2 template`:
.. _`org.sysess.sympathy.texts.generic_jinja2template`:
Jinja2 template
```````````````
.. image:: jinja_template.svg
:width: 48
Create and render a jinja2 template. Use "{{arg}}" for access to the data.
Documentation
:::::::::::::
Create and render a jinja2 template. See `Jinja2
`_ for full syntax of the template engine.
Input data can be of any type and is accessed using {{arg}}.
The examples below assume that the first input is a table.
Example of iterating over each column::
{% for name in arg.column_names() %}
The column name is: {{name}}
The column data is:
{% for value in arg.col(name).data %} {{value}} {% endfor %}
{% endfor %}
Example of iterating over one specific column::
{% for value in arg.col('Foo').data %}
{{ value }}
{% endfor %}
Example of iterating over each row::
{% for row in arg.to_rows() %}
{% for value in row %} {{value}} {% endfor %}
{% endfor %}
The examples below assume that you have created a tuple or list of tables
as input::
{% for tbl in arg %}
Table name: {{ tbl.name }}
{% for col in tbl.cols() %}
{{ col.name }}: {% for x in col.data %} {{x}} {% endfor %}
{% endfor %}
{% endfor %}
Finally, you can connect complex datatypes such as an ADAF to the node::
{% for name, col in arg.sys['system0']['raster0'].items() %}
Signal: {{name}}
Time: {{ col.t }}
Value: {{ col.y }}
{% endfor %}
Have a look at the :ref:`Data type APIs` to see what methods
and attributes are available on the data type that you are working with.
Definition
::::::::::
Input ports
...........
**in** 0 - 1,
Input
Output ports
............
**out** text
Rendered Template
Configuration
.............
**Template** (template)
Enter template here
Examples
........
* :download:`Jinja2.syx `
* :download:`Custom bokeh template.syx `
Implementation
..............
.. automodule:: node_text_operations
:noindex:
.. class:: Jinja2Template
:noindex: